<?php
/**
 * Created by PhpStorm.
 * Admininfo: Administrator
 * Date: 2017/12/11
 * Time: 16:53
 */
namespace app\admin\controller;
use app\admin\model\Article;
use app\admin\model\Cate;
use app\common\controller\Baseadmin;
use think\Request;
use think\Session;
use app\admin\model\Menu;
use app\admin\model\Admingroup;

class Controller extends Baseadmin
{
	public function __construct(Request $request = null)
	{
		parent::__construct($request);
	}
	public  function index(){
		if(!Session::get('userid')) {
			$this->redirect('Index/index');
	     }
        $Menumodel=new Menu();
		if(Session::get('userinfo.user_group_id')!=1){
		    $Usergroup=new Admingroup();
            $infos=$Usergroup::get(Session::get('userinfo.user_group_id'));
            $list=$Menumodel->getchildlist($infos['menu']);
        }else{
            $list=$Menumodel->getchildlist();
        }
        $list = collection($list)->toArray();
		return $this->fetch('index',['list'=>$list]);
 	}
	public function welcome(){
		return	$this->fetch();
	}
    /**
     * 退出登录
     */
    public function logout(){
        Session::clear();
        return  $this->redirect('Index/login');
    }

}